﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mr.Data
{
    public class AutoCreateEntity
    {
        public static void initDBEntity()
        {
            var db = new SqlSugarClient(new ConnectionConfig()
            {
                ConnectionString = ConfigurationManager.AppSettings["sqlconn"],
                DbType = DbType.SqlServer,
                InitKeyType = InitKeyType.Attribute,//从特性读取主键和自增列信息
                IsAutoCloseConnection = true,
            });
            db.DbFirst
            .SettingClassTemplate(old =>
            {
                return old.Replace("{Namespace}", "Mr.Data.Entities");               
            })
            .CreateClassFile(@"C:\Users\Administrator\source\repos\TestSqlSurging\Mr.Data\Entities");
            db.Dispose();
        }
    }
}
